<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
 
	<link  rel="stylesheet" type="text/css" href="css/navigator.css" />
	<script type="text/javascript" language="javascript" src="js/jquery-1.7.1.js"></script>
	<script>
		$(function(){
			$('#addProjectForm').hide();
			$('input[value="add"]').click(function(){
				 $('#addProjectForm').toggle();
			});
			
			$('input[value="delete"]').click(function(){
				var i=$('input:checked').length;
			 	var url='deleteProject?';
				//var pid=new Array();
				if(i<1){
					alert('please choose at least one project!');
				}else{
				
					$('input:checked').each(function(){
					 	url=url+'pid='+$(this).attr('value')+'&';
					});
					url=url.slice(0,-1);
					//后台删除数据
					//pid=$.param(pid,true);
					$.ajax({
					  url: url,
					  cache:false,
					  success: function(returnData, textStatus) {
					  	  $('input:checked').each(function(){
					 			$(this).parent().parent().hide();
							});
						},
					    error: function(xhr, textStatus, errorThrown) {
					      	alert('faile');
					    }
					});
				}
				
			});
			
			$('input[value="detail"]').click(function(){
				var i=$('input:checked').length;
				if(i!=1){
					alert('please choose exactly one project!');
				}else{
					//window.location.href="admin/detail.jsp";
					var pid;
					var url='detailAction?pid=';
					$('input:checked').each(function(){
						pid=$(this).attr('value');
						url+=pid;
					});
					window.open(url);
				}
			});
		});
	</script>
  </head>
  
  <body>
    <div id='navigator'>
		<div class="imcm imde" id="imouter0">
				<ul id="imenus0">
					<li class="imatm"  style="width:99px;">
						<a class="" href="index.jsp">
							projects
						</a>
					</li>
					<li class="imatm"  style="width:99px;">
						<a class="" href="accountManage.action?manageTarget=account" target='_blank'>
							users
						</a>
					</li>
				</ul>
			<div class="imclear">&nbsp;</div>
		</div>
	</div>
	
	<table border="1">
		<tr>
			<td>
				choose
			</td>
			<td>
				project name
			</td>
			<td>
				description
			</td>
			<td>
				create time
			</td>
		</tr>
		<s:iterator value="projectList" id="list" status="st">
		<tr>
			<td>
				<input  type="checkbox" value='<s:property value="#list.pid" />' />
			</td>
			<td>
				<s:property value="#list.title" /> 
			</td>
			<td>
				<s:property value="#list.description" /> 
			</td>
			<td>
				<s:property value="#list.time" /> 
			</td>
		</tr>
		</s:iterator>
	</table>
	
	<tr>
		<input type="button" value='add' />
		<input type="button" value='delete' />
		<input type="button" value='detail' />
		<br/>
		<input type="button" value='trace' />
		<input type="button" value='changeControl' />
	</tr>
	
	<form id='addProjectForm' action='addProject' method='post'>
	<table>
		<tr>
			<td>
				title
			</td>
			<td>
				<input type='text' name='title' />
			</td>
		</tr>
		<tr>
			<td>
				description
			</td>
			<td>
				<textarea rows="10" cols="100" name='description'></textarea>
			</td>
		</tr>
		<tr>
			<td></td>
			<td>
				<input type='submit' value='submit' />
			</td>
		</tr>
	</table>
	</form>

  </body>
</html>
